package com.media.utils

import android.Manifest
import android.content.Intent
import com.baselibrary.activity.BaseActivity
import com.baselibrary.permission.PermissionCollection
import com.baselibrary.permission.PermissionsUtils
import com.baselibrary.permission.callback.PermissionsCall
import com.baselibrary.utils.DoubleClickHelper
import com.media.image.ImageModel
import com.media.revision.RevisionMediaActivity

object WineryAboutUtils {
    /**选择 图片视频
     * @author: merbng
     * @time: 2022/7/12 13:33
     * @description: isHaveVideo：true 图片视频都可选择  false：只可选择图片
     * fileCnt：已选的数量
     * maxCnt：可选择的最大数量
     */
    fun uploadImgVideo(act: BaseActivity, isHaveVideo: Boolean, fileCnt: Int, maxCnt: Int) {
        if (!DoubleClickHelper.isOnDoubleClick()) {
            PermissionsUtils.getInstance().chekPermissions(act, PermissionCollection.CUSTOM.addPermissionList(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA), object : PermissionsCall() {
                override fun permissionsPass() {
                    val intent = Intent(act, RevisionMediaActivity::class.java)
                    intent.putExtra("type", if (isHaveVideo) ImageModel.TYPE_ALL else ImageModel.TYPE_IMAGE)
                    intent.putExtra("maxstr", maxCnt - fileCnt)
                    intent.putExtra("isPassEventbus", true)
                    act.startActivity(intent)
                }
            })
        }
    }
}